<?php if(!defined('IN_DISCUZ')) exit('Access Denied'); hookscriptoutput('add');?><?php include template('common/header'); ?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ADD</title>
    <link rel="stylesheet" href="style/base.css">
    <script src="style/jquery.js" type="text/javascript"></script>
</head>
<body>

<!-- plugin.php?id=zhibo&ac=activity&op=post -->
<!--https://bikeshopapi.olbike.com/V2/?service=Live.Add-->
直播名称:<input type="text" name="channelName" id="channelName" value="123"/><br>
直播描述:<input type="text" name="channelDescribe" id="channelDescribe" value="123"/><br>
开始时间:<input type="text" name="startTime" id="activeTime" value="18:04:13-18:08:30"/><br>
封面图片:<input type="text" name="logo" id="logo" value="123"/><br>
输出源名称:<input type="text" name="sourceName" id="sourceName" value="123"/><br>
<input type="hidden" name="sourceType" value='1' id="sourceType"/>
选择输出源:
<select name="outputSourceType" id="outputSourceType">
    <option value="3">RTMP/FLV HLS输出</option>
</select><br>
输出画质: <input type="checkbox" name="outputRate" value="0" checked="checked"/>原画
<input type="checkbox" name="outputRate" value="10" checked="checked"/>标清
<input type="checkbox" name="outputRate" value="20"/>高清<br>
显示水印:
<select name="watermarkId" id="watermarkId">
    <option value="1">显示水印</option>
    <option value="0">不显示水印</option>
</select><br>
<button id="add">提交</button>

<script>
    OLBIKEjq(function () {
        OLBIKEjq("#add").click(function () {
            obj = OLBIKEjq("input[name='outputRate']");
            check_val = [];
            for (k in obj) {
                if (obj[k].checked)
                    check_val.push(obj[k].value);
            }
            console.log(check_val);
            OLBIKEjq.ajax({
//                https://bikeshopapi.olbike.com/V2/?service=Live.Add
                url: 'https://bikeshopapi.olbike.com/V2/?service=Live.Add',
                type: 'post',
                dataType: 'json',
                data: {
                    "channelName": OLBIKEjq("#channelName").val(),
                    "outputSourceType": OLBIKEjq("#outputSourceType").val(),
                    "channelDescribe": OLBIKEjq("#channelDescribe").val(),
                    "sourceName": OLBIKEjq("#sourceName").val(),
                    "sourceType": OLBIKEjq("#sourceType").val(),
                    "outputRate": check_val,
                },
                success: function (msg) {
                    var a = new Array();
                    a[0] = msg.data.downstream_address[0]['rtmp_downstream_address'];
                    a[1] = msg.data.downstream_address[1]['rtmp_downstream_address'];
                    OLBIKEjq.post('http://localhost/bikeshop/shopapi/V3/?service=Active.Add',{
                        "username": "<?php echo $_G['username'];?>",
                        "channelName" : OLBIKEjq("#channelName").val(),
                        "channelDescribe" : OLBIKEjq("#channelDescribe").val(),
                        "activeTime" : OLBIKEjq("#activeTime").val(),
                        "logo" : OLBIKEjq("#logo").val(),
                        "outputSourceType" : OLBIKEjq("#outputSourceType").val(),
                        "outputRate" : check_val,
                        "watermarkId": OLBIKEjq("#watermarkId").val(),
                        "channelId" : msg.data.channel_id,
                        "address" : a
                    },function(data){

                        console.log(data);
                    });
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        });
    });
</script>

</body>
</html><?php include template('common/footer'); ?>